Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

core/repository/src/commonMain/kotlin/org/meshtastic/core/repository/PacketRepository.kt e85300531e124df08788c1b765d50af1bf6d516d (e8530053) Text, 8.79 KB

T8b949e/*
* Copyright (c) 2025-2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.repository

Tff7b72import T7ee787androidx.paging.PagingData
Tff7b72import T7ee787kotlinx.coroutines.flow.Flow
Tff7b72import T7ee787org.meshtastic.core.model.ContactSettings
Tff7b72import T7ee787org.meshtastic.core.model.DataPacket
Tff7b72import T7ee787org.meshtastic.core.model.Message
Tff7b72import T7ee787org.meshtastic.core.model.MessageStatus
Tff7b72import T7ee787org.meshtastic.core.model.Node
Tff7b72import T7ee787org.meshtastic.core.model.Reaction
Tff7b72import T7ee787org.meshtastic.proto.ChannelSettings

T8b949e/**
* Repository interface for managing mesh packets and message history.
*
* This component provides methods for persisting received packets, querying message history, tracking unread counts,
* and managing contact-specific settings. It supports both reactive (Flow) and one-shot (suspend) queries.
*/
Tf0883e@SuppressTb4b4b4(Ta5d6ff"Ta5d6ffTooManyFunctionsTa5d6ff"Tb4b4b4)
Tff7b72interface T56d364PacketRepository Tb4b4b4{
T8b949e/** Reactive flow of all persisted waypoints (GPS locations). */
Tff7b72fun Td2a8ffgetWaypointsTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Te6edf3ListTff7b72<Te6edf3DataPacketTff7b72>Tff7b72>

T8b949e/** Reactive flow of all conversation contacts, keyed by their contact identifier. */
Tff7b72fun Td2a8ffgetContactsTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Te6edf3MapTff7b72<Tffa657StringTb4b4b4, Te6edf3DataPacketTff7b72>Tff7b72>

T8b949e/** Reactive paged flow of conversation contacts. */
Tff7b72fun Td2a8ffgetContactsPagedTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Te6edf3PagingDataTff7b72<Te6edf3DataPacketTff7b72>Tff7b72>

T8b949e/** Returns the total number of messages in a conversation. */
Tff7b72suspend Tff7b72fun Td2a8ffgetMessageCountTb4b4b4(Te6edf3contactTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Tffa657Int

T8b949e/** Returns the count of unread messages in a conversation. */
Tff7b72suspend Tff7b72fun Td2a8ffgetUnreadCountTb4b4b4(Te6edf3contactTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Tffa657Int

T8b949e/** Reactive flow of the unread message count in a conversation. */
Tff7b72fun Td2a8ffgetUnreadCountFlowTb4b4b4(Te6edf3contactTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Tffa657IntTff7b72>

T8b949e/** Reactive flow of the UUID of the first unread message in a conversation. */
Tff7b72fun Td2a8ffgetFirstUnreadMessageUuidTb4b4b4(Te6edf3contactTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Tffa657Long?Tff7b72>

T8b949e/** Reactive flow indicating whether a conversation has any unread messages. */
Tff7b72fun Td2a8ffhasUnreadMessagesTb4b4b4(Te6edf3contactTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Tffa657BooleanTff7b72>

T8b949e/** Reactive flow of the total unread message count across all conversations. */
Tff7b72fun Td2a8ffgetUnreadCountTotalTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Tffa657IntTff7b72>

T8b949e/** Clears the unread status for messages in a conversation up to the given timestamp. */
Tff7b72suspend Tff7b72fun Td2a8ffclearUnreadCountTb4b4b4(Te6edf3contactTb4b4b4: Tffa657StringTb4b4b4, Te6edf3timestampTb4b4b4: Tffa657LongTb4b4b4)

T8b949e/** Clears the unread status for all messages across all conversations. */
Tff7b72suspend Tff7b72fun Td2a8ffclearAllUnreadCountsTb4b4b4(Tb4b4b4)

T8b949e/** Updates the identifier of the last read message in a conversation. */
Tff7b72suspend Tff7b72fun Td2a8ffupdateLastReadMessageTb4b4b4(Te6edf3contactTb4b4b4: Tffa657StringTb4b4b4, Te6edf3messageUuidTb4b4b4: Tffa657LongTb4b4b4, Te6edf3lastReadTimestampTb4b4b4: Tffa657LongTb4b4b4)

T8b949e/** Returns all packets currently queued for transmission. */
Tff7b72suspend Tff7b72fun Td2a8ffgetQueuedPacketsTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3ListTff7b72<Te6edf3DataPacketTff7b72>Tff7b72?

T8b949e/**
* Persists a packet in the database.
*
* @param myNodeNum The local node number at the time of receipt.
* @param contactKey The identifier of the associated conversation.
* @param packet The [DataPacket] to save.
* @param receivedTime The timestamp (ms) the packet was received.
* @param read Whether the packet should be marked as already read.
* @param filtered Whether the packet was filtered by message rules.
*/
Tff7b72suspend Tff7b72fun Td2a8ffsavePacketTb4b4b4(
Te6edf3myNodeNumTb4b4b4: Tffa657IntTb4b4b4,
Te6edf3contactKeyTb4b4b4: Tffa657StringTb4b4b4,
Te6edf3packetTb4b4b4: Te6edf3DataPacketTb4b4b4,
Te6edf3receivedTimeTb4b4b4: Tffa657LongTb4b4b4,
Te6edf3readTb4b4b4: Tffa657Boolean Tff7b72= Tff7b72trueTb4b4b4,
Te6edf3filteredTb4b4b4: Tffa657Boolean Tff7b72= Tff7b72falseTb4b4b4,
Tb4b4b4)

T8b949e/**
* Returns a reactive flow of messages for a conversation.
*
* @param contact The conversation identifier.
* @param limit Optional maximum number of messages to return.
* @param includeFiltered Whether to include messages that were marked as filtered.
* @param getNode Callback to fetch node info for message sender attribution.
*/
Tff7b72suspend Tff7b72fun Td2a8ffgetMessagesFromTb4b4b4(
Te6edf3contactTb4b4b4: Tffa657StringTb4b4b4,
Te6edf3limitTb4b4b4: Tffa657Int? Tff7b72= Tff7b72nullTb4b4b4,
Te6edf3includeFilteredTb4b4b4: Tffa657Boolean Tff7b72= Tff7b72trueTb4b4b4,
Te6edf3getNodeTb4b4b4: Te6edf3suspend Tb4b4b4(Tffa657String?Tb4b4b4) Tff7b72-Tff7b72> Te6edf3NodeTb4b4b4,
Tb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Te6edf3ListTff7b72<Te6edf3MessageTff7b72>Tff7b72>

T8b949e/** Returns a paged flow of messages for a conversation. */
Tff7b72fun Td2a8ffgetMessagesFromPagedTb4b4b4(Te6edf3contactTb4b4b4: Tffa657StringTb4b4b4, Te6edf3getNodeTb4b4b4: Te6edf3suspend Tb4b4b4(Tffa657String?Tb4b4b4) Tff7b72-Tff7b72> Te6edf3NodeTb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Te6edf3PagingDataTff7b72<Te6edf3MessageTff7b72>Tff7b72>

T8b949e/** Returns a paged flow of messages for a conversation, with filtering options. */
Tff7b72fun Td2a8ffgetMessagesFromPagedTb4b4b4(
Te6edf3contactKeyTb4b4b4: Tffa657StringTb4b4b4,
Te6edf3includeFilteredTb4b4b4: Tffa657BooleanTb4b4b4,
Te6edf3getNodeTb4b4b4: Te6edf3suspend Tb4b4b4(Tffa657String?Tb4b4b4) Tff7b72-Tff7b72> Te6edf3NodeTb4b4b4,
Tb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Te6edf3PagingDataTff7b72<Te6edf3MessageTff7b72>Tff7b72>

T8b949e/** Updates the transmission status of a packet. */
Tff7b72suspend Tff7b72fun Td2a8ffupdateMessageStatusTb4b4b4(Te6edf3dTb4b4b4: Te6edf3DataPacketTb4b4b4, Te6edf3mTb4b4b4: Te6edf3MessageStatusTb4b4b4)

T8b949e/** Updates the identifier of a persisted packet. */
Tff7b72suspend Tff7b72fun Td2a8ffupdateMessageIdTb4b4b4(Te6edf3dTb4b4b4: Te6edf3DataPacketTb4b4b4, Te6edf3idTb4b4b4: Tffa657IntTb4b4b4)

T8b949e/** Deletes messages by their database UUIDs. */
Tff7b72suspend Tff7b72fun Td2a8ffdeleteMessagesTb4b4b4(Te6edf3uuidListTb4b4b4: Te6edf3ListTff7b72<Tffa657LongTff7b72>Tb4b4b4)

T8b949e/** Deletes all messages and settings for the given contacts. */
Tff7b72suspend Tff7b72fun Td2a8ffdeleteContactsTb4b4b4(Te6edf3contactListTb4b4b4: Te6edf3ListTff7b72<Tffa657StringTff7b72>Tb4b4b4)

T8b949e/** Deletes a waypoint by its ID. */
Tff7b72suspend Tff7b72fun Td2a8ffdeleteWaypointTb4b4b4(Te6edf3idTb4b4b4: Tffa657IntTb4b4b4)

T8b949e/** Reactive flow of all contact settings (e.g., mute status). */
Tff7b72fun Td2a8ffgetContactSettingsTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Te6edf3MapTff7b72<Tffa657StringTb4b4b4, Te6edf3ContactSettingsTff7b72>Tff7b72>

T8b949e/** Returns the settings for a specific contact. */
Tff7b72suspend Tff7b72fun Td2a8ffgetContactSettingsTb4b4b4(Te6edf3contactTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Te6edf3ContactSettings

T8b949e/** Mutes the given contacts until the specified timestamp. */
Tff7b72suspend Tff7b72fun Td2a8ffsetMuteUntilTb4b4b4(Te6edf3contactsTb4b4b4: Te6edf3ListTff7b72<Tffa657StringTff7b72>Tb4b4b4, Te6edf3untilTb4b4b4: Tffa657LongTb4b4b4)

T8b949e/** Reactive flow of the number of filtered messages for a contact. */
Tff7b72fun Td2a8ffgetFilteredCountFlowTb4b4b4(Te6edf3contactKeyTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Tffa657IntTff7b72>

T8b949e/** Returns the total count of filtered messages for a contact. */
Tff7b72suspend Tff7b72fun Td2a8ffgetFilteredCountTb4b4b4(Te6edf3contactKeyTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Tffa657Int

T8b949e/** Disables or enables message filtering for a specific contact. */
Tff7b72suspend Tff7b72fun Td2a8ffsetContactFilteringDisabledTb4b4b4(Te6edf3contactKeyTb4b4b4: Tffa657StringTb4b4b4, Te6edf3disabledTb4b4b4: Tffa657BooleanTb4b4b4)

T8b949e/** Clears all packet and message history from the database. */
Tff7b72suspend Tff7b72fun Td2a8ffclearPacketDBTb4b4b4(Tb4b4b4)

T8b949e/** Migrates channel-specific message history when encryption keys change. */
Tff7b72suspend Tff7b72fun Td2a8ffmigrateChannelsByPSKTb4b4b4(Te6edf3oldSettingsTb4b4b4: Te6edf3ListTff7b72<Te6edf3ChannelSettingsTff7b72>Tb4b4b4, Te6edf3newSettingsTb4b4b4: Te6edf3ListTff7b72<Te6edf3ChannelSettingsTff7b72>Tb4b4b4)

T8b949e/** Marks all messages from a specific sender as filtered or unfiltered. */
Tff7b72suspend Tff7b72fun Td2a8ffupdateFilteredBySenderTb4b4b4(Te6edf3senderIdTb4b4b4: Tffa657StringTb4b4b4, Te6edf3filteredTb4b4b4: Tffa657BooleanTb4b4b4)

T8b949e/** Returns a packet by its mesh-layer packet ID. */
Tff7b72suspend Tff7b72fun Td2a8ffgetPacketByPacketIdTb4b4b4(Te6edf3packetIdTb4b4b4: Tffa657IntTb4b4b4)Tb4b4b4: Te6edf3DataPacket?

T8b949e/** Returns a packet by its internal database ID. */
Tff7b72suspend Tff7b72fun Td2a8ffgetPacketByIdTb4b4b4(Te6edf3idTb4b4b4: Tffa657IntTb4b4b4)Tb4b4b4: Te6edf3DataPacket?

T8b949e/** Inserts a packet into the database. */
Tff7b72suspend Tff7b72fun Td2a8ffinsertTb4b4b4(
Te6edf3packetTb4b4b4: Te6edf3DataPacketTb4b4b4,
Te6edf3myNodeNumTb4b4b4: Tffa657IntTb4b4b4,
Te6edf3contactKeyTb4b4b4: Tffa657StringTb4b4b4,
Te6edf3receivedTimeTb4b4b4: Tffa657LongTb4b4b4,
Te6edf3readTb4b4b4: Tffa657Boolean Tff7b72= Tff7b72trueTb4b4b4,
Te6edf3filteredTb4b4b4: Tffa657Boolean Tff7b72= Tff7b72falseTb4b4b4,
Tb4b4b4)

T8b949e/** Updates an existing packet in the database, optionally setting a routing error code. */
Tff7b72suspend Tff7b72fun Td2a8ffupdateTb4b4b4(Te6edf3packetTb4b4b4: Te6edf3DataPacketTb4b4b4, Te6edf3routingErrorTb4b4b4: Tffa657Int Tff7b72= Tff7b72-T79c0ff1Tb4b4b4)

T8b949e/** Persists a message reaction (emoji). */
Tff7b72suspend Tff7b72fun Td2a8ffinsertReactionTb4b4b4(Te6edf3reactionTb4b4b4: Te6edf3ReactionTb4b4b4, Te6edf3myNodeNumTb4b4b4: Tffa657IntTb4b4b4)

T8b949e/** Updates an existing reaction. */
Tff7b72suspend Tff7b72fun Td2a8ffupdateReactionTb4b4b4(Te6edf3reactionTb4b4b4: Te6edf3ReactionTb4b4b4)

T8b949e/** Returns a reaction associated with a specific packet ID. */
Tff7b72suspend Tff7b72fun Td2a8ffgetReactionByPacketIdTb4b4b4(Te6edf3packetIdTb4b4b4: Tffa657IntTb4b4b4)Tb4b4b4: Te6edf3Reaction?

T8b949e/** Finds all packets matching a specific packet ID. */
Tff7b72suspend Tff7b72fun Td2a8fffindPacketsWithIdTb4b4b4(Te6edf3packetIdTb4b4b4: Tffa657IntTb4b4b4)Tb4b4b4: Te6edf3ListTff7b72<Te6edf3DataPacketTff7b72>

T8b949e/** Finds all reactions associated with a specific packet ID. */
Tff7b72suspend Tff7b72fun Td2a8fffindReactionsWithIdTb4b4b4(Te6edf3packetIdTb4b4b4: Tffa657IntTb4b4b4)Tb4b4b4: Te6edf3ListTff7b72<Te6edf3ReactionTff7b72>

T8b949e/**
* Updates the Store-and-Forward PlusPlus (SFPP) status for packets.
*
* @param packetId The packet ID.
* @param from The sender node number.
* @param to The recipient node number.
* @param hash The SFPP commit hash.
* @param status The new SFPP-specific message status.
* @param rxTime The receipt time from the mesh.
* @param myNodeNum The local node number.
*/
Tff7b72suspend Tff7b72fun Td2a8ffupdateSFPPStatusTb4b4b4(
Te6edf3packetIdTb4b4b4: Tffa657IntTb4b4b4,
Te6edf3fromTb4b4b4: Tffa657IntTb4b4b4,
Te6edf3toTb4b4b4: Tffa657IntTb4b4b4,
Te6edf3hashTb4b4b4: Te6edf3ByteArrayTb4b4b4,
Te6edf3statusTb4b4b4: Te6edf3MessageStatusTb4b4b4,
Te6edf3rxTimeTb4b4b4: Tffa657LongTb4b4b4,
Te6edf3myNodeNumTb4b4b4: Tffa657Int?Tb4b4b4,
Tb4b4b4)

T8b949e/** Updates the SFPP status of packets matching the given commit hash. */
Tff7b72suspend Tff7b72fun Td2a8ffupdateSFPPStatusByHashTb4b4b4(Te6edf3hashTb4b4b4: Te6edf3ByteArrayTb4b4b4, Te6edf3statusTb4b4b4: Te6edf3MessageStatusTb4b4b4, Te6edf3rxTimeTb4b4b4: Tffa657LongTb4b4b4)
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.06s